package ConcurrentModifyException;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wangyg6 on 2017/11/28.
 */
public class WorkClass {
	private volatile static WorkClass instance = new WorkClass();

	private WorkClass() {
	}

	public static WorkClass getInstance() {
		return instance;
	}

	public List<String> list() {
		List<String> list = new ArrayList<>();
		list.add("1");
		list.add("2");
		list.add("3");
		list.add("4");
		list.add("5");
		list.add("6");
		list.add("7");
		list.add("8");
		list.add("9");
		list.add("10");
		list.add("11");
		list.add("12");
		list.add("13");
		list.add("14");
		list.add("15");
		return list;
	}

	public void doWork() {
		List<String> list = list();
		for (String s : list) {
			System.out.println(Thread.currentThread().getName() + ":" + s);
		}
	}
}
